StringFunctions.Trim function

Removes whitespace from a string

Format

ANSI-SQL Format:

TRIM ( [ { LEADING | TRAILING | BOTH } [ PadChar ] FROM ] expression )

ODBC Format:

{{ FN { LTRIM | RTRIM } ( expression ) }}

Remarks

The TRIM function returns a character string identical to the given character string, except that leading and/or trailing pad characters have been removed.

The PadChar argument is optional, and if specified defines the pad character that will be removed from the character string. If PadChar is not specified, the pad character is defaulted to a space.

The use of the optional keyword LEADING, TRAILING or BOTH controls whether the pad character is removed from the start of the string (LEADING), the end of the string (TRAILING), or both the start and the end of the string (BOTH). If this keyword is missing, BOTH is assumed.

If both PadChar and the LEADING/TRAILING/BOTH keywords are omitted, the FROM keyword must also be omitted.

The equivalent ODBC functions are LTRIM and RTRIM. The ODBC expression {FN LTRIM( String )} is equivalent to TRIM( LEADING FROM String ). The ODBC expression {FN RTRIM( String )} is equivalent to TRIM( TRAILING FROM String ).

Example:

TRIM( ' Leading and trailing spaces will be removed ' )

TRIM( TRAILING '.' FROM CurrentStateDesc )

{FN RTRIM( 'Traling spaces will be removed ' )}


Disclaimer

Geo SCADA Expert 2019